const url = require("url")

// console.log(url)

var str = "http://www.baidu.com:3000/abc/qwe/zxc/index.html?username=admin&password=123#top";

var urlObj = url.parse(str, true)

console.log(urlObj)

var obj = {
    protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'www.baidu.com:3000',
    port: '3000',
    hostname: 'www.baidu.com',
    hash: '#top',
    search: '?username=admin&password=123',
    query: { username: 'admin', password: '123' },
    pathname: '/abc/qwe/zxc/index.html',
    path: '/abc/qwe/zxc/index.html?username=admin&password=123',
    href: 'http://www.baidu.com:3000/abc/qwe/zxc/index.html?username=admin&password=123#top'
}

console.log(url.format(obj))


